/**
 * sysLoginLogServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:登陆日志管理
 * 
 * 历史版本:2017-03-27 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.sys.sysLoginLog.service.impl;

import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.common.util.SqlUtil;
import com.fmjr.sys.sysLoginLog.bean.SysLoginLog;
import com.fmjr.sys.sysLoginLog.dao.SysLoginLogDao;
import com.fmjr.sys.sysLoginLog.service.ISysLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service("sysLoginLogService")
public class  SysLoginLogServiceImpl implements ISysLoginLogService {
	

	@Autowired
    private SysLoginLogDao sysLoginLogDao;

	/**
	 * 根据条件查询登陆日志记录
	 * @author lunli
	 * @param  pager
	 * @return SysLoginLogList
	 * @throws BusinessException
	 */
	public void selectSysLoginLogList(Pager<SysLoginLog> pager) throws BusinessException{
		int totalCount = sysLoginLogDao.selectSysLoginLogCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<SysLoginLog> list = sysLoginLogDao.selectSysLoginLogList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询登陆日志记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public SysLoginLog selectSysLoginLogById(Long id) throws BusinessException{
		return sysLoginLogDao.selectSysLoginLogById(id);
	}

	/**
	 *  删除登陆日志记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteSysLoginLogById(Long id) throws BusinessException{
		return sysLoginLogDao.deleteSysLoginLogById(id);
	}
	
	/**
	 * 修改登陆日志记录
	 * @author lunli
	 * @param sysLoginLog
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateSysLoginLog(SysLoginLog sysLoginLog) throws BusinessException{
		return sysLoginLogDao.updateSysLoginLog(sysLoginLog);
	}

	/**
	 * 新增登陆日志记录
	 * @author lunli
	 * @param sysLoginLog
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createSysLoginLog(SysLoginLog sysLoginLog) throws BusinessException{
		return sysLoginLogDao.createSysLoginLog(sysLoginLog);
	}
	

	

}
